package com.example.content.adapter.viewpager

import android.util.Log
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter

/**
 * Created by zhudongao
 * Desc
 * Date 2020/9/20
 */
class HomePagerAdapter(fm: FragmentManager, private val fragments: List<Fragment>, private val titles:Array<String>) :
    FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {

    override fun getCount(): Int {
        return fragments.size
    }

    override fun getItem(position: Int): Fragment {
        return fragments[position]
    }

    override fun getPageTitle(position: Int): CharSequence? {
        Log.i("MainActivity", "getPageTitle: pageTitle position：$position")
        return titles[position % titles.size]
    }
}